﻿using SuperX.DataService.Abstract;
using SuperX.TimeManagerService;
using System;
using System.Collections.Generic;
using System.Text;

namespace SuperX.DataService
{
    public class TagTimeCase : BaseTimer
    {
        private Dictionary<string, IIOTag> _dic = new Dictionary<string, IIOTag>();

        public TagTimeCase(string name, double interval) : base(name, interval)
        {
        }

        /// <summary>
        /// IOTag变量增加到词典
        /// </summary>
        /// <param name="tag"></param>
        public void Add(IIOTag tag)
        {
            if (_dic.ContainsKey(tag.FullName)) return;
            _dic[tag.FullName] = tag;
        }

        public override void Run()
        {
            foreach (var item in _dic.Values)
            {
                item.Update(item.Value, DateTime.Now, Common.QUALITIES.OK);
            }
        }
    }
}